//@filename: ADC.h
//@date: 2019-07-22
//@author: 闫锐
//@brief: 模拟量转换数字量
#ifndef _RCS_ADC_H_
#define _RCS_ADC_H_

// C语言公共库
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>

// BSP与中间件
#include "stm32f4xx.h"      //STM32寄存器定义
#include "stm32f4xx_conf.h" //STM32标准库头文件
#include "bsp.h"            //uCOS底层组件
#include "includes.h"       //uCOS必备组件
#include "delay.h"          //延时函数

// RCSLIB硬件抽象层
#include "RCS_Types.h"       //获取MCU的外设-时钟连接关系
#include "RCS_HAL.h"         //获取MCU的寄存器定义
#include "RCS_Pin_Mapping.h" //主控板的引脚映射和外设映射

#define LASER_ADC_ONE       ADC1
#define LASER_GPIO_ONE      GPIOA
#define LASER_PIN_ONE       GPIO_Pin_4
#define LASER_CHANNEL_ONE   ADC_Channel_4

#define LASER_ADC_TWO       ADC1
#define LASER_GPIO_TWO      GPIOA
#define LASER_PIN_TWO       GPIO_Pin_5
#define LASER_CHANNEL_TWO   ADC_Channel_5

#define LASER_ADC_THREE     ADC1
#define LASER_GPIO_THREE    GPIOA
#define LASER_PIN_THREE     GPIO_Pin_6
#define LASER_CHANNEL_THREE ADC_Channel_6

#define LASER_ADC_FOUR      ADC1
#define LASER_GPIO_FOUR     GPIOA
#define LASER_PIN_FOUR      GPIO_Pin_7
#define LASER_CHANNEL_FOUR  ADC_Channel_7

#define VOLTAGE_REFERANCE   3.3f // 鍙傝€冪數鍘?
#define MAX_RANGE           4096 // 鏈€澶ч噺绋?

//@name: RCS_ADC_Init
//@brief: 鍒濆�嬪寲ADC
//@param:ADC_TypeDef *_ADCx ADC鍙?
//@param:GPIO_TypeDef *_GPIOx GPIO缁?
//@param:uint32_t _pin 绠¤剼
//@note:娴嬮噺鐢靛帇涓嶅緱瓒呰繃3.3V
void RCS_ADC_Init(ADC_TypeDef *_ADCx, GPIO_TypeDef *_GPIOx, uint32_t _pin);

//@name: RCS_Get_ADC
//@brief: 鑾峰彇ADC鐨勫€?
//@param:ADC_TypeDef *_ADCx ADC鍙?
//@param:ADC_Channel_x 绠¤剼閫氶亾鍙?
uint16_t RCS_Get_ADC(ADC_TypeDef *_ADCx, uint8_t ADC_Channel_x);

//@name: RCS_Get_Voltage
//@brief: 鑾峰彇ADC鐨勭數鍘嬪€?
//@param:ADC_TypeDef *_ADCx ADC鍙?
//@param:_channel 绠¤剼閫氶亾鍙?
float RCS_Get_Voltage(ADC_TypeDef *_ADCx, uint8_t ADC_Channel_x);

#endif
